package com.neutech.solar.util;

import com.neutech.solar.constant.Constant;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

public class ImageUtil {

    //Map<key,value>
    public static Map<String,Image> maps = new HashMap<>();
    static {
        maps.put("bg",ImageUtil.getImage("bg.jpg"));
        maps.put("sun",ImageUtil.getImage("sun.png"));
        maps.put("Mercury",ImageUtil.getImage("mercury.png"));
        maps.put("Venus",ImageUtil.getImage("venus.png"));
        maps.put("Earth",ImageUtil.getImage("earth.png"));
        maps.put("Mars",ImageUtil.getImage("mars.png"));
        maps.put("Jupiter",ImageUtil.getImage("jupiter.png"));
        maps.put("Saturn",ImageUtil.getImage("saturn.png"));
        maps.put("Uranus",ImageUtil.getImage("uranus.png"));
        maps.put("Neptune",ImageUtil.getImage("neptune.png"));
        maps.put("smallPlanet",ImageUtil.getImage("pluto.png"));
    }
    private ImageUtil() {}
    public static Image getImage(String imageName) {
        URL u = ImageUtil.class.getClassLoader().getResource(Constant.IMAGE_PATH_PRE + imageName);
            BufferedImage img = null;
            try {
                img = ImageIO.read(u);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return img;
        }


    }
